package com.example.tb_log.log;

import android.content.Context;

/**
 * TbLog的配置类
 */
public abstract class TbLogConfig {
    static int MAX_LEN = 512;//一行显示最大的长度：512个字符
    static TbThreadFormatter TB_THREAD_FORMATTER = new TbThreadFormatter();
    static TbStackTraceFormatter TB_STACK_TRACE_FORMATTER = new TbStackTraceFormatter();

    private Context context;
    private String crashLogPath;
    private boolean enableCrashHandler = true;

    public TbLogConfig(Context context) {
        this.context = context.getApplicationContext();
    }

    public JsonParser injectJsonParser() {
        return null;
    }

    public String getGlobalTag() {
        return "TbLog";
    }

    public boolean enable() {
        return true;
    }

    public boolean includeThread() {
        return false;
    }

    public int stackTraceDepth() {
        return 5;
    }

    public TbLogPrinter[] printers() {
        return null;
    }

    public boolean enableCrashHandler() {
        return enableCrashHandler;
    }

    public void setEnableCrashHandler(boolean enableCrashHandler) {
        this.enableCrashHandler = enableCrashHandler;
    }

    public String getCrashLogPath() {
        if (crashLogPath == null) {
            // 默认保存在应用的外部存储目录下的crash文件夹中
            crashLogPath = context.getExternalFilesDir(null) + "/crash";
        }
        return crashLogPath;
    }

    public void setCrashLogPath(String crashLogPath) {
        this.crashLogPath = crashLogPath;
    }

    public Context getContext() {
        return context;
    }

    public interface JsonParser {
        String toJson(Object src);
    }
}
